package com.wlcj.www.job;

import java.io.Serializable;
import java.util.List;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.wlcj.util.RedisUtil;
import com.wlcj.www.model.main.Content;
import com.wlcj.www.model.main.Friendlink;
import com.wlcj.www.model.main.Penster;
import com.wlcj.www.util.DataUtil;


public class IndexJob extends BaseJob implements Job{

	@Override
	public void execute(JobExecutionContext jec) throws JobExecutionException {
		int[] guanggaoweiids = new int[]{2420,2421,2422,2423,2713,2424};
		List<Content> guanggaowei = Content.dao.getListByIds(guanggaoweiids);
		List<Friendlink> friendlinklist = Friendlink.dao.getList();
		List<Content> gundonglist = Content.dao.getListByTypeId(2, 0, 4);
		List<Content> gundongrightlist = Content.dao.getListByTypeId(3, 0, 4);
		List<Content> toutiaolist = Content.dao.getTouTiaoListByTypeId(4, 0,8);
		for (int i = 0; i < toutiaolist.size(); i++) {
			Content c =(Content)toutiaolist.get(i);
			c.set("sort_date", DataUtil.timeTop(String.valueOf(c.get("sort_date"))));
			toutiaolist.set(i, c);
		}
		List<Content> pingtaigonggaolist = Content.dao.getListByChannelId(98, 0,5);
		List<Content> zhongguancunjinronglist = Content.dao.getListByChannelId(173, 0,5);//
		List<Content> dalaofangtanlist = Content.dao.getListByChannelId(175, 0,6);//
		for (int i = 0; i < dalaofangtanlist.size(); i++) {
			Content c =(Content)dalaofangtanlist.get(i);
			c.set("sort_date", String.valueOf(c.get("sort_date")).substring(2, 10).replaceAll("-", "/"));
			dalaofangtanlist.set(i, c);
		}
		List<Content> weilaiwangpingList = Content.dao.getListByChannelId(82, 0,6);
		for (int i = 0; i < weilaiwangpingList.size(); i++) {
			Content c =(Content)weilaiwangpingList.get(i);
			c.set("sort_date", String.valueOf(c.get("sort_date")).substring(2, 10).replaceAll("-", "/"));
			weilaiwangpingList.set(i, c);
		}
		List<Content> wangqingjianceList = Content.dao.getListByChannelId(79, 0,5);
		List<Content> manhuajinrongList = Content.dao.getListByChannelId(40, 0,9);
		List<Penster> zhuanlanplist = Penster.dao.getListByRecommend(0, 4);
		List<Penster> zhuanlanclist = Penster.dao.getListByChannelId(174,0, 9);//
		List<Content> caizhiyuedulist = Content.dao.getListByChannelId(176, 0,5);//
		
		List<Content> pingtaidongtailist = Content.dao.getListByChannelIds(new int[]{98,104}, 0,8);
		for (int i = 0; i < pingtaidongtailist.size(); i++) {
			Content c =(Content)pingtaidongtailist.get(i);
			c.set("sort_date", String.valueOf(c.get("sort_date")).substring(2, 10).replaceAll("-", "/"));
			pingtaidongtailist.set(i, c);
		}
		Long start = System.currentTimeMillis();
		RedisUtil.set("guanggaoweilist", (Serializable)guanggaowei);
		RedisUtil.set("friendlinklist", (Serializable)friendlinklist);
		RedisUtil.set("gundonglist", (Serializable)gundonglist);
		RedisUtil.set("gundongrightlist", (Serializable)gundongrightlist);
		RedisUtil.set("toutiaolist", (Serializable)toutiaolist);
		RedisUtil.set("pingtaigonggaolist", (Serializable)pingtaigonggaolist);
		RedisUtil.set("zhongguancunjinronglist", (Serializable)zhongguancunjinronglist);
		RedisUtil.set("dalaofangtanlist", (Serializable)dalaofangtanlist);
		RedisUtil.set("weilaiwangpingList", (Serializable)weilaiwangpingList);
		RedisUtil.set("wangqingjianceList", (Serializable)wangqingjianceList);
		RedisUtil.set("manhuajinrongList", (Serializable)manhuajinrongList);
		RedisUtil.set("zhuanlanplist", (Serializable)zhuanlanplist);
		RedisUtil.set("zhuanlanclist", (Serializable)zhuanlanclist);
		RedisUtil.set("caizhiyuedulist", (Serializable)caizhiyuedulist);
		RedisUtil.set("pingtaidongtailist", (Serializable)pingtaidongtailist);
		long end = System.currentTimeMillis()-start;
		System.out.println("*******************************首页缓存数据消耗了："+end+"毫秒*******************************");
	}
}
